function deepClone(obj){
    if(typeof obj!== 'object' || obj instanceof RegExp || obj instanceof Date) return obj
    
    //保持克隆后的对象类型
    const cloneObj = new obj.constructor

    for(const key in obj){
        if(obj.hasOwnProperty(key))
            cloneObj[key] = deepClone(obj[key])
    }

    return cloneObj
}

const obj = {
    a:100,
    b:[10,20,30],
    c:{
        x:10
    },
    d:/^\d+$/,
    e:Date.now()
}

const test = deepClone(obj)
console.log(test);
test.c.x=100
console.log(obj.c.x===test.c.x);
console.log(obj.constructor);